import 'dart:convert' show json;

import 'package:x3_base_core/base_models/base_model_asT.dart';

class BaseCustomCheckboxListTileModel<T> {
  BaseCustomCheckboxListTileModel({
    this.key,
    this.title,
    this.isChecked,
    this.value,
  });

  factory BaseCustomCheckboxListTileModel.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : BaseCustomCheckboxListTileModel(
          key: asT<int>(jsonRes['key']),
          title: asT<String>(jsonRes['title']),
          isChecked: asT<bool>(jsonRes['isChecked'] ?? false),
          value: asT<T>(jsonRes['value']),
        );

  int key;
  String title;
  bool isChecked;
  T value;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'key': key,
        'title': title,
        'isChecked': isChecked,
        'value': value,
      };
  @override
  String toString() {
    return json.encode(this);
  }
}
